package com.smartwasser.yunhtgl.apphtgl.activity;

import android.os.Handler;
import android.text.TextUtils;
import android.view.View;

import com.smartwasser.yunhtgl.apphtgl.R;
import com.smartwasser.yunhtgl.apphtgl.base.BaseActivity;
import com.smartwasser.yunhtgl.apphtgl.utils.AppConfigSP;

/**
 * 欢迎界面
 */
public class SplashActivity extends BaseActivity {
    private Handler handler = new Handler();
    private AppConfigSP sp;
    private Boolean isFirst;

    @Override
    public void setContentLayout() {
        sp = new AppConfigSP(getApplicationContext());
        isFirst = sp.getFirst();
        if (isFirst) {
            setContentView(R.layout.activity_first);
        } else {
            setContentView(R.layout.activity_splash);
        }
    }

    @Override
    public void initView() {
    }

    @Override
    public void initData() {
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                String gesturePassword = sp.getGesturePassword();
                if (isFirst) {
                    startActivity(StartOnceActivity.class);
                    sp.setFirst(false);
                    finish();
                } else {
                    if (TextUtils.isEmpty(gesturePassword)) {
                        startActivity(LoginActivity.class);
                    } else {
                        startActivity(GestureGetActivity.class);
                    }
                    finish();
                }
            }
        }, 1000);
    }

    @Override
    public void onClick(View view) {
    }
}
